home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Developer / StopWatch / Source / ColCell.m < prev    next >
Encoding:
Text File  |  1994-02-04  |  1.2 KB  |  67 lines

  1. /*
  2.  * For legal stuff see the file COPYRIGHT
  3.  */
  4. #import "ColCell.h"
  5.  
  6. /* Font info */
  7. static NXCoord ascender, descender, lineHeight;
  8.  
  9. @implementation ColCell
  10.  
  11. - (void)setCellData:(id <ColCellData>)obj
  12. {
  13.   [self setStringValue:""];
  14.   data = obj;
  15. }
  16.  
  17. - (id <ColCellData>)cellData
  18. {
  19.   return data;
  20. }
  21.  
  22. - setFont:fontObj
  23. {
  24.   [super setFont:fontObj];
  25.   /*
  26.    * save this info so we don't have to look it up every time we draw
  27.    * Note:  support for a TextCell is a font object
  28.    */
  29.   NXTextFontInfo(support, &ascender, &descender, &lineHeight);
  30.   return self;
  31. }    
  32.  
  33. /*
  34.  * Override the drawing method to put the data in two columns
  35.  */
  36. - drawInside:(const NXRect *)cellFrame inView:controlView
  37. {
  38.   NXCoord baseX, baseY;
  39.   ColDesc *colDesc = [data colDesc];
  40.  
  41.   baseX = NX_X(cellFrame);
  42.   baseY = NX_Y(cellFrame) + lineHeight - descender;
  43.  
  44.   [super drawInside:cellFrame inView:controlView];
  45.   PSsetgray(NX_BLACK);
  46.  
  47.   if ( colDesc ) {
  48.     for ( ; colDesc->method; colDesc++ ) {
  49.       PSmoveto( baseX + colDesc->offset, baseY );
  50.       PSshow( (const char *)[(id)data perform:colDesc->selector] );
  51.     }
  52.   }
  53.  
  54.   return self;
  55. }
  56.  
  57. - copyFromZone:(NXZone *)zone
  58. {
  59.   ColCell *copy;
  60.  
  61.   copy = [super copyFromZone:zone];
  62.   copy->data = data;
  63.   return copy;
  64. }
  65.  
  66. @end
  67.